package tools;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import domain.Stu;
import domain.Student;

public class ReadTool {
	private String path;

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}
	
	public List<Stu> readUsers(){
		//返回一个学生list
		BufferedReader br=null;
		List<Stu>list=new ArrayList<Stu>();
		try {
			br=new BufferedReader(new FileReader(path));//读取要导入学生信息的文件(文档文件)
			String str;
			while((str=br.readLine())!=null) {
				if(str.equals(""))continue;
				String id=str.split(",")[0];
				String name=str.split(",")[1];
				String course=str.split(",")[2];
				String classes=str.split(",")[3];
				String score=str.split(",")[4];			
				Stu s=new Stu();s.setID(Integer.parseInt(id));s.setName(name);s.setClasses(classes);s.setCourse(course);s.setScore(score);
				list.add(s);
			}
		} catch (FileNotFoundException ex) {
			ex.printStackTrace();
		} catch (IOException ioException) {
			ioException.printStackTrace();
		}
		return list;
	}
}
